package com.uvnos4j.matilda.system.domain;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.uvnos4j.matilda.commons.domain.AbstractTreeDomain;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;

/**
 * 部门
 * <p>
 * Description:部门
 * </p>
 *
 * @author Guo.wl
 * @version v1.0.0
 * @see com.uvnos4j.matilda.system.domain
 * @since 2020-08-31 23:13:00
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName(value = "sys_dept")
public class SysDept extends AbstractTreeDomain<SysDept> implements Serializable {

    private static final long serialVersionUID = 1L;
    /**
     * 部门名称
     */
    @TableField(value = "name")
    private String name;
    /**
     * 上级部门id
     */
    @JsonSerialize(using = ToStringSerializer.class)
    @TableField(value = "parent_id")
    private Long parentId;
    /**
     * 部门层级
     */
    @TableField(value = "level")
    private String level;
    /**
     * 部门在当前层级下的顺序，由小到大
     */
    @TableField(value = "seq")
    private Integer seq;
    /**
     * 备注
     */
    @TableField(value = "note")
    private String note;
    /**
     * 操作者
     */
    @TableField(value = "operator")
    private String operator;

    @Override
    public boolean isRoot() {
        return parentId == null || parentId == 0;
    }

}